﻿#region zh-CHS 2006 - 2007 DemoSoft 团队 | en 2006 - 2007 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the G.O.S.E(Game Online Server Engine) for .NET.
//
//                 2006-2007 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using System.Runtime.InteropServices;
using Demo_G.O.S.E.ServerEngine.Common;
#endregion

namespace Demo_G.O.S.E.ServerEngine.Network.DLL
{
    /// <summary>
    /// 网络的数据包
    /// </summary>
    [MultiThreadedSupportgAttribute( "当前的类所有成员都可锁定,支持多线程操作" )]
    public class ACEMessageBlock
    {
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 网络的数据包的指针
        /// </summary>
        private IntPtr m_Value  = IntPtr.Zero;
        #endregion

        #region zh-CHS 共有属性 | en Public Properties
        /// <summary>
        /// 数据已经读取的长度
        /// </summary>
        public int ReadLength
        {
            get { return ACEMessageBlock_ReadLength(m_Value); }
        }

        /// <summary>
        /// 数据已经写入的长度
        /// </summary>
        public int WriteLength
        {
            get { return ACEMessageBlock_WriteLength(m_Value); }
        }

        /// <summary>
        /// 数据包的长度
        /// </summary>
        public int Length
        {
            get { return ACEMessageBlock_Length(m_Value); }
        }

        /// <summary>
        /// 数据包的大小
        /// </summary>
        public int Size
        {
            get { return ACEMessageBlock_Size(m_Value); }
        }

        /// <summary>
        ///  数据包的容量
        /// </summary>
        public int Capacity
        {
            get { return ACEMessageBlock_Capacity(m_Value); }
        }
        #endregion

        #region zh-CHS 共有方法 | en Public Methods
        /// <summary>
        /// 数据包的基指针
        /// </summary>
        /// <returns></returns>
        public IntPtr BaseIntPtr()
        {
            return ACEMessageBlock_BaseIntPtr(m_Value);
        }

        /// <summary>
        /// 数据包的读指针
        /// </summary>
        /// <returns></returns>
        public IntPtr ReadIntPtr()
        {
            return ACEMessageBlock_ReadIntPtr(m_Value);
        }

        /// <summary>
        /// 数据包的写指针
        /// </summary>
        /// <returns></returns>
        public IntPtr WriteIntPtr()
        {
            return ACEMessageBlock_WriteIntPtr(m_Value);
        }

        /// <summary>
        /// 数据包的读指针的位置
        /// </summary>
        /// <param name="readLength"></param>
        public void ReadIntPtrLength(int readLength)
        {
            ACEMessageBlock_ReadIntPtrLength(readLength, m_Value);
        }

        /// <summary>
        /// 数据包的写指针的位置
        /// </summary>
        /// <param name="writeLength"></param>
        public void WriteIntPtrLength(int writeLength)
        {
            ACEMessageBlock_WriteIntPtrLength(writeLength, m_Value);
        }

        /// <summary>
        /// 数据包的指针复原位置
        /// </summary>
        public void Reset()
        {
            ACEMessageBlock_Reset(m_Value);
        }
        #endregion

        #region zh-CHS 内部属性 | en Internal Properties
        /// <summary>
        /// 网络的数据包的指针
        /// </summary>
        protected internal IntPtr Value
        {
            get { return m_Value; }
            set { m_Value = value; }
        }
        #endregion

        #region zh-CHS 引入DLL接口 | en DLL Import
        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern IntPtr ACEMessageBlock_BaseIntPtr(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern IntPtr ACEMessageBlock_ReadIntPtr(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern IntPtr ACEMessageBlock_WriteIntPtr(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="readLength"></param>
        /// <param name="pMessageBlock"></param>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern void ACEMessageBlock_ReadIntPtrLength(int readLength, IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="writeLength"></param>
        /// <param name="pMessageBlock"></param>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern void ACEMessageBlock_WriteIntPtrLength(int writeLength, IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern void ACEMessageBlock_Reset(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int ACEMessageBlock_ReadLength(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int ACEMessageBlock_WriteLength(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int ACEMessageBlock_Length(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int ACEMessageBlock_Size(IntPtr pMessageBlock);

        /// <summary>
        /// dll 调用
        /// </summary>
        /// <param name="pMessageBlock"></param>
        /// <returns></returns>
        [DllImport("Demo G.O.S.E.Net.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int ACEMessageBlock_Capacity(IntPtr pMessageBlock);
        #endregion
    }
}
#endregion

